package mil.af.amc.adpetracker.web.decorators;

import org.displaytag.decorator.TableDecorator;
import mil.af.amc.adpetracker.model.DRA;
import mil.af.amc.adpetracker.util.LinkBuilder;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */

public class DraDecorator extends TableDecorator {

    public String getName() {

        DRA dra = (DRA) getCurrentRowObject();
        return dra.getName();

    }

    public int getAssignedAccounts() {

        DRA dra = (DRA) getCurrentRowObject();
        return dra.getAdpeAccounts().size();
    }

    public String getActions() {

        DRA dra = (DRA) getCurrentRowObject();
        StringBuilder sb = new StringBuilder();

        LinkBuilder editLink = new LinkBuilder();
        editLink.setName("Edit");
        editLink.setBaseUrl("draAction.do");
        editLink.addParameter("method","viewEditPage");
        editLink.addParameter("draId", dra.getId());

        sb.append(editLink.getLink(LinkBuilder.LINK_TEXT, true));
        sb.append("&nbsp;");

        LinkBuilder deleteLink = new LinkBuilder();
        deleteLink.setName("Delete");
        deleteLink.setBaseUrl("draAction.do");
        deleteLink.addParameter("method","deleteDra");
        deleteLink.addParameter("draId", dra.getId());

        sb.append(deleteLink.getLink(LinkBuilder.LINK_TEXT, true));

        return sb.toString();

    }
}
